import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import axios from 'axios'
import api from '../assets/config/api.js'
export default new Vuex.Store({
  state: {
    cartTotal:{
      checkedGoodsAmount: 0,
      checkedGoodsCount: 0,
      goodsAmount: 0,
      goodsCount: 0,
    },
    cartList:[],

  },
  mutations: {
    setCarlist:function(state,cartList){
      state.cartList=cartList;
    },
    setCarTotal:function(state,cartTotal){
      state.cartTotal=cartTotal
    }
  },
  actions: {
    AjaxCart:async function(content){
      let carRes=await axios.get(api.CartList);
      console.log(carRes.data);
      content.commit('setCarlist',carRes.data.data.cartList);
      content.commit('setCarTotal',carRes.data.data.cartTotal);
    }
  },
  modules: {
  }
});